package com.dlc.shop.api.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dlc.shop.bean.model.UserExtension;
import com.dlc.shop.common.response.ServerResponseEntity;
import com.dlc.shop.security.api.util.SecurityUtils;
import com.dlc.shop.service.UserExtensionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author gaozijie
 * @date 2023-09-01
 */
@Tag(name = "用户拓展信息")
@RestController
@RequestMapping("/p/userExtension")
@AllArgsConstructor
public class UserExtensionController {

    private final UserExtensionService userExtensionService;

    @GetMapping("/getInfo")
    @Operation(summary = "获取用户拓展信息详情")
    public ServerResponseEntity<UserExtension> getInfo() {
        String userId = SecurityUtils.getUser().getUserId();
        UserExtension userExtension = userExtensionService.getOne(new LambdaQueryWrapper<UserExtension>()
                .eq(UserExtension::getUserId, userId));
        return ServerResponseEntity.success(userExtension);
    }
}
